package tp.badugi.bot.guiViewsBot;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import tp.badugi.bot.GuiClientWithBot;

public class GetNicknameViewBot extends JFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6152482465082076236L;
	
	private GuiClientWithBot client;
	
	private final Dimension nicknameViewSize = new Dimension(200,100);
	
	private final Dimension serverViewSize = new Dimension(500, 300);

	private JPanel nicknamePanel = new JPanel();
	
	public JTextField nicknameTextField = new JTextField("Your nickname");
	
	public JButton nicknameJoin = new JButton("Join");	

	public GetNicknameViewBot(GuiClientWithBot client) {

		this.client = client;
		
		this.setTitle(this.client.title);
		
		this.setBounds(
				(int)(this.client.windowBoundPoint.getX() + (this.serverViewSize.getWidth()-this.nicknameViewSize.getWidth())/2),
				(int)(this.client.windowBoundPoint.getY() + (this.serverViewSize.getHeight()-this.nicknameViewSize.getHeight())/2),
				(int)this.nicknameViewSize.getWidth(), (int)this.nicknameViewSize.getHeight());
		
		this.nicknamePanel.setBackground(Color.BLUE);
		
		this.nicknamePanel.setLayout(new GridLayout(2,1));
		this.nicknamePanel.setBorder(new EmptyBorder(10, 30, 10, 30) );
		this.add(this.nicknamePanel);
		
		this.nicknamePanel.add(this.nicknameTextField);
		this.nicknameJoin.addActionListener(this.client);
		this.nicknamePanel.add(this.nicknameJoin);
		
		this.setUndecorated(true);
		this.setVisible(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	}
}
